@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">创建作业</h5>
                </div>

                <div class="card-body">
                    <form method="POST" action="{{ route('assignments.store') }}">
                        @csrf

                        <div class="mb-3">
                            <label for="source" class="form-label">作业来源</label>
                            <select class="form-select @error('source') is-invalid @enderror" id="source" name="source" required>
                                <option value="">请选择</option>
                                <option value="school" {{ old('source') === 'school' ? 'selected' : '' }}>学校作业</option>
                                <option value="institution" {{ old('source') === 'institution' ? 'selected' : '' }}>机构作业</option>
                            </select>
                            @error('source')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mb-3">
                            <label for="subject" class="form-label">科目</label>
                            <select class="form-select @error('subject') is-invalid @enderror" id="subject" name="subject" required>
                                <option value="">请选择</option>
                                <option value="chinese" {{ old('subject') === 'chinese' ? 'selected' : '' }}>语文</option>
                                <option value="math" {{ old('subject') === 'math' ? 'selected' : '' }}>数学</option>
                                <option value="english" {{ old('subject') === 'english' ? 'selected' : '' }}>英语</option>
                                <option value="science" {{ old('subject') === 'science' ? 'selected' : '' }}>科学</option>
                            </select>
                            @error('subject')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mb-3">
                            <label for="type" class="form-label">作业类型</label>
                            <select class="form-select @error('type') is-invalid @enderror" id="type" name="type" required>
                                <option value="">请选择</option>
                                <option value="daily" {{ old('type') === 'daily' ? 'selected' : '' }}>每日作业</option>
                                <option value="weekly" {{ old('type') === 'weekly' ? 'selected' : '' }}>每周作业</option>
                                <option value="checkin" {{ old('type') === 'checkin' ? 'selected' : '' }}>每日打卡</option>
                            </select>
                            @error('type')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mb-3">
                            <label for="content" class="form-label">作业内容</label>
                            <textarea class="form-control @error('content') is-invalid @enderror" id="content" name="content" rows="3" required>{{ old('content') }}</textarea>
                            @error('content')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mb-3">
                            <label for="due_date" class="form-label">截止日期</label>
                            <input type="date" class="form-control @error('due_date') is-invalid @enderror"   
                                id="due_date" name="due_date" value="{{ old('due_date') }}" required
                                onclick="this.showPicker()">  <!-- 关键代码 -->
                            @error('due_date')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="d-grid">
                            <button type="submit" class="btn btn-primary">创建作业</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection 